package com.atguigu.gmall.fastdfs;

import org.aspectj.weaver.ast.Var;

import java.util.concurrent.*;

/**
 * @Auther 赵乾坤
 * @Date 2020-12-26 13:02
 */
public class ThreadDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //单个线程
//        new Thread(()->{
//            System.out.println(Thread.currentThread().getName());
//        },"AAAA").start();
//        //线程池
//        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
//                        10, 20,
//                        60L, TimeUnit.SECONDS,
//                        new ArrayBlockingQueue<>(5));
//        //执行过程 ： 线程池中有0个线程
//        // 1：大量请求来了  先找核心线程  10个  超过10个了 排队 5个   最大20  默认直接抛异常
//
//        threadPoolExecutor.execute(() ->{
//            System.out.println(Thread.currentThread().getName());
//        });
//        //中间人
//        FutureTask futureTask = new FutureTask(()->{
//            System.out.println(Thread.currentThread().getName());
//            return "ahhhhhh";
//        });
//
//
//        threadPoolExecutor.execute(futureTask);
//        //返回值
//        System.out.println(futureTask.get());

        new Thread(()->{
            System.out.println(Thread.currentThread().getName());
        },"AAAA").start();
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
                10,
                20,
                60L,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(5)
        );
        threadPoolExecutor.execute(()->{
            System.out.println(Thread.currentThread().getName());
        });
        //中间人  是为了 有返回值哦
        FutureTask futureTask = new FutureTask(()->{
            System.out.println(Thread.currentThread().getName());
            return "ahhhh";
        });


    }



//   class  MyThread extends Thread{
//       @Override
//       public void run() {
//           System.out.println(Thread.currentThread().getName());
//       }
//   }
}
class  MyCallAble implements Callable{

    @Override
    public Object call() throws Exception {
        return null;
    }
}
